import http from './http'

export async function getTravelPlans(params = {}) {
  const { data } = await http.get('/api/travel-plans', { params })
  return Array.isArray(data?.data) ? data.data : []
}

export async function getTravelPlanById(id) {
  const { data } = await http.get(`/api/travel-plans/${id}`)
  return data?.data || null
}

export async function createTravelPlan(payload) {
  const { data } = await http.post('/api/travel-plans', payload)
  return data?.data
}

export async function updateTravelPlan(id, payload) {
  const { data } = await http.put(`/api/travel-plans/${id}`, payload)
  return data?.data
}

export async function deleteTravelPlan(id) {
  const { data } = await http.delete(`/api/travel-plans/${id}`)
  return !!data?.success
}